package com.primb.bench.base;

import android.app.Application;
import android.content.Context;
import android.graphics.Point;
import android.view.WindowManager;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.primb.baselibs.util.PreferencesUtils;
import com.primb.bench.common.constant.AppConstant;
import com.primb.bench.common.override.CrashHandler;
import com.primb.netlibs.config.ApiConstants;
import com.tencent.bugly.Bugly;
import com.zhy.autolayout.config.AutoLayoutConifg;



/**
 * Created by Chen on 2017/4/13.
 * 功能描述：
 */

public class IApplication extends Application {
    public static Context applicationContext;
    private String TAG = "---BigManger---";

    @Override
    public void onCreate() {
        super.onCreate();
        applicationContext = this;
        String ip = PreferencesUtils.getString(this, "ip");
        if (ip != null && !ip.equals("")) {
            ApiConstants.BASE_URL = ip;
        }
        AutoLayoutConifg.getInstance().useDeviceSize();
        WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
        Point point = new Point();
        wm.getDefaultDisplay().getSize(point);
        AppConstant.SCREEN_WIDTH = point.x;
        AppConstant.SCREEN_HEIGHT = point.y;
        Logger.init(TAG).methodCount(3).methodOffset(2).logLevel(LogLevel.FULL);
//        JPushInterface.setDebugMode(true);
//        JPushInterface.init(this);
//        //全局异常捕获
//        CrashHandler crashHandler = CrashHandler.getInstance();
//        //注册crashHandler
//        crashHandler.init(getApplicationContext());
        Bugly.init(getApplicationContext(), "26fdccc572", false);
    }

    public static Context getInstance() {
        return applicationContext;
    }

}
